package net.itren.jetpackdemo.observer

import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent

//MyObserver作为一个观察者来监听有生命周期的类
class MyObserver : LifecycleObserver {
    @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
    fun ON_CREATE() {
        Log.e(this.javaClass.name, "ON_CREATE")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_START)
    fun ON_START() {
        Log.e(this.javaClass.name, "ON_START")

    }

    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
    fun ON_RESUME() {
        Log.e(this.javaClass.name, "ON_RESUME")

    }

    @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
    fun ON_PAUSE() {
        Log.e(this.javaClass.name, "ON_PAUSE")

    }

    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
    fun ON_STOP() {
        Log.e(this.javaClass.name, "ON_STOP")

    }

    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    fun ON_DESTROY() {
        Log.e(this.javaClass.name, "ON_DESTROY")

    }

    @OnLifecycleEvent(Lifecycle.Event.ON_ANY)
    fun ON_ANY() {
        Log.e(this.javaClass.name, "ON_ANY")

    }

}